//
//  UILabel+QSGradientColor.m
//  CFGradientLabelDemo
//
//  Created by apple on 2017/8/8.
//  Copyright © 2017年 于 传峰. All rights reserved.
//

#import "UILabel+QSGradientColor.h"

@implementation UILabel (QSGradientColor)
- (void)addGradientColorLayerWithStartPoint:(CGPoint)startP endPoint:(CGPoint)endP startColor:(UIColor *)startC endColor:(UIColor *)endC
{
    // 创建渐变层
    CAGradientLayer* gradientLayer = [CAGradientLayer layer];
    gradientLayer.frame = self.frame;
    gradientLayer.colors = [NSArray arrayWithObjects:(id)startC.CGColor, (id)endC.CGColor, nil];
    gradientLayer.startPoint = startP;
    gradientLayer.endPoint = endP;
    [self.superview.layer addSublayer:gradientLayer];
    
    gradientLayer.mask = self.layer;
    self.frame = gradientLayer.bounds;
}
@end
